package InformationExtraction;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Vector;

import DB.Table;

/*
 * Help class for our use only
 * this class helped us for seeing results from the extraction of the data to Tables 
 */
public class Data {

	private Vector<Table> tables;

	public Data(Vector<Table> tables) {
		this.tables = tables;
	}

	public Data() {
		this.tables = new Vector<Table>();
	}

	public void addTbale(Table t){
		this.tables.add(t);
	}

	public Table getTable(String name){
		for(Table t : tables)
			if(t.getName().equalsIgnoreCase(name))
				return t;
		return null;
	}

	public void printData(){
		for(Table t : tables)
			t.print();
	}

	public void printToFile(String fileName){
		try{
			// Create file 
			FileWriter fstream = new FileWriter(fileName);
			BufferedWriter out = new BufferedWriter(fstream);
			for(Table t : tables)
				t.printToFile(out);
			//Close the output stream
			out.close();
		}catch (Exception e){//Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}

		
	}






}
